﻿<UserControl x:Class="Kokomo.PeInspector.Reflection.TypeMembersView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:ui="clr-namespace:Kokomo;assembly=Kokomo.UI"
			 xmlns:r="clr-namespace:Kokomo.PeInspector.Reflection"
			 xmlns:pe="clr-namespace:Kokomo.PeInspector"
			 xmlns:env="xaml://kokomo/environment"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
	<DockPanel>
		<Expander Header="Options" DockPanel.Dock="Bottom">
			<StackPanel>
				<CheckBox IsChecked="{Binding IncludeHiddenMembers, Mode=TwoWay}" Content="Include hidden members"/>
				<CheckBox IsChecked="{Binding GroupMembersByType, Mode=TwoWay}" Content="Group members by type"/>
			</StackPanel>
		</Expander>

		<pe:SearchView
			SearchTerm="{Binding SearchTerm}"
			IsSearching="{Binding IsSearching}"
			SearchProgress="{Binding SearchProgress}"
			>
			<ListView
				ItemsSource="{Binding Results}"
				TextSearch.TextPath="MemberName"
				ui:ListViewHelper.IsSortingEnabled="True"
				ui:ListViewHelper.ItemActivatedCommand="{Binding NavigateToCommand}"
				>
				<ListView.ItemContainerStyle>
					<Style>
						<Setter Property="ui:ListViewHelper.ItemParameter" Value="{Binding Member}"/>
					</Style>
				</ListView.ItemContainerStyle>
				<ListView.View>
					<GridView>
						<GridViewColumn Header="Name">
							<GridViewColumn.CellTemplate>
								<DataTemplate DataType="{x:Type r:TypeMemberItem}">
									<ContentPresenter Content="{Binding ViewInfo}"/>
								</DataTemplate>
							</GridViewColumn.CellTemplate>
						</GridViewColumn>
					</GridView>
				</ListView.View>
				<ListView.GroupStyle>
					<GroupStyle>
						<GroupStyle.ContainerStyle>
							<Style TargetType="{x:Type GroupItem}">
								<Setter Property='Template'>
									<Setter.Value>
										<ControlTemplate TargetType="{x:Type GroupItem}">
											<Expander IsExpanded="True">
												<Expander.Template>
													<ControlTemplate TargetType="{x:Type Expander}">
														<Grid>
															<Grid.RowDefinitions>
																<RowDefinition Height="Auto"/>
																<RowDefinition Height="Auto"/>
															</Grid.RowDefinitions>

															<Grid>
																<Grid.ColumnDefinitions>
																	<ColumnDefinition Width="Auto"/>
																	<ColumnDefinition Width="*"/>
																</Grid.ColumnDefinitions>

																<ToggleButton
																	VerticalAlignment="Center"
																	IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
																	Style="{DynamicResource {x:Static env:EditorStyleKeys.ExpandCollapseArrowStyleKey}}"
																	/>
																	<!--<ToggleButton.Template>
																		<ControlTemplate TargetType="{x:Type ToggleButton}">
																			<Path
																				x:Name="Arrow"
																				Width="5"
																				Height="9"
																				Stroke="Black"
																				Fill="Black"
																				Margin="6"
																				Data="M 0,0 L 0,8 L 4,4 Z"
																				/>
																			<ControlTemplate.Triggers>
																				<Trigger Property="IsChecked" Value="True">
																					<Setter TargetName="Arrow" Property="Data" Value="M 0,4 L 4,0 L 4,4 Z"/>
																				</Trigger>
																			</ControlTemplate.Triggers>
																		</ControlTemplate>
																	</ToggleButton.Template>
																</ToggleButton>-->

																<ContentPresenter
																	Grid.Column="1"
																	ContentSource="Header"
																	/>
															</Grid>

															<ContentPresenter
																Grid.Row="1"
																x:Name="ContentRow"
																>
															</ContentPresenter>
														</Grid>
														<ControlTemplate.Triggers>
															<Trigger Property="IsExpanded" Value="False">
																<Setter TargetName="ContentRow" Property="Visibility" Value="Collapsed"/>
															</Trigger>
														</ControlTemplate.Triggers>
													</ControlTemplate>
												</Expander.Template>

												<Expander.Header>
													<TextBlock FontWeight="Bold">
														<TextBlock.Text>
															<Binding Path="Name" StringFormat="{}{0} members"/>
														</TextBlock.Text>
													</TextBlock>
												</Expander.Header>
												<Expander.Content>
													<ItemsPresenter Margin="12 0 0 0"/>
												</Expander.Content>
											</Expander>
										</ControlTemplate>
									</Setter.Value>
								</Setter>
							</Style>
						</GroupStyle.ContainerStyle>
					</GroupStyle>
				</ListView.GroupStyle>
			</ListView>
		</pe:SearchView>
	</DockPanel>
</UserControl>
